package 尚硅谷juc大厂.test20;

import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.util.concurrent.TimeUnit;

class MyObject{

    /**
     *每个对象在被GC回收之前都会调用finalize()方法
     */
    @Override
    protected void finalize() throws Throwable {
        System.out.println("finalize方法执行.......");
    }
}
public class Test20 {
    public static void main(String[] args) {
        MyObject object = new MyObject();
        WeakReference wrf=new WeakReference(object);
        object=null;
        System.out.println("未发生GC之前"+wrf.get());
        System.gc();
        System.out.println("内存充足，发生GC之后"+wrf.get());
    }
}
